<?php
class Default_Form_Register_ValidateImage{
	
	static function validate($arrParam = null, $options = null){
		
		$upload = new Zend_File_Transfer_Adapter_Http();
		$config = new Zendvn_Controller_Config(array('module'=> 'default',
													'fileConfig'=>'user.ini'));
		$configObj = $config->getConfig('config');
	
		$fileInfo = $upload->getFileInfo('avatar');
		$fileName = $fileInfo['avatar']['name'];
		if(!empty($fileName)){
			$options = $configObj['extension'];
			$upload->addValidator('Extension',true,$options,'image')
			 	   ->addValidator('Size',true,array('min'=>$configObj['min-size'],'max'=>$configObj['max-size']),'avatar');
			if(!$upload->isValid('avatar')){
				$message = $upload->getMessages();
				$error = current($message);							
			}
		}
		return @$error;	
	}
	
}